package com.edu.exam.enums.assessment.plan;

import com.edu.exam.enums.core.StatusEnum;
import lombok.Getter;

/**
 * 评估计划审核结果枚举
 * 用于评估计划的审核流程
 */
@Getter
public enum AssessmentPlanAuditResult implements StatusEnum {
    
    APPROVED("0", "通过"),
    REJECTED("1", "拒绝"),
    CONDITIONAL_APPROVAL("2", "有条件通过"),
    MAJOR_REVISION("3", "重大修改"),
    MINOR_REVISION("4", "轻微修改"),
    RESUBMIT("5", "重新提交"),
    DEFERRED("6", "延期"),
    WITHDRAWN("7", "撤回"),
    EXEMPT("8", "免除"),
    PENDING("9", "待定");
    
    private final String code;
    private final String description;
    
    AssessmentPlanAuditResult(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public static AssessmentPlanAuditResult fromCode(Integer code) {
        if (code == null) {
            return PENDING;
        }
        for (AssessmentPlanAuditResult result : values()) {
            if (result.getCode().equals(code)) {
                return result;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
    
    public static AssessmentPlanAuditResult fromDescription(String description) {
        if (description == null) {
            return PENDING;
        }
        for (AssessmentPlanAuditResult result : values()) {
            if (result.getDescription().equals(description)) {
                return result;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }
}